import LocalStorage from '../../model/localStorage.js'
import { ConsumerReceivePiece, validata } from '@/model/consumerReceivePiece.js'
import { toGetReceivePieceByConsumerIdAndtatus } from 'api/user.js'
import {Toast} from 'vant'
const orderMixin = {
    data() {
        return {
           OrderMixinList:"",
           offset:1
        }
    },
    created() {
         //登陆时通过id 和 删选条件 
        // console.log("orderMixin","shit")
        if(LocalStorage.get('token')){
           
            const state =0+""
        //    this.getOrderMixinList(state )
        }else{
            this.OrderMixinList=[]
            this.finished=true
        }
    },
    methods: {
        getOrderMixinList(state){
            // this.OrderMixinList=[{a:3}]
            const {consumerId ,  phone} =  JSON.parse(this.$store.state.app.userInfo)
            let consumerPiece=new ConsumerReceivePiece(consumerId,state,phone,this.offset,this.pageSize )
            console.log(consumerPiece)
            // consumerId , status,  phone
            if(validata(consumerPiece,ConsumerReceivePiece)){
                let data=consumerPiece._getData() 
                toGetReceivePieceByConsumerIdAndtatus(data).then(res=>{
                    console.log(res)
                    if(res.data.result.list.length == 0){
                        this.finished=true
                    }else{
                        this.isBg=false
                    }
                    this.OrderMixinList=  res.data.result.list

                  this.list=  this.list.concat( this.OrderMixinList)
                  this.loading = false
               
                }).catch(err=>{
                    this.finished=true
                    Toast.fail({
                        message:err
                    })
                })
             
                
            }
             

        }
    },
}
export default orderMixin;